package com.zjj.lbw.microservice.seata.account.seataaccountservice.controller;

import com.zjj.lbw.microservice.seata.account.seataaccountservice.service.AccountService;
import com.zjj.lbw.microservice.seata.account.seataaccountservice.service.TCCAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author zhanglei.zjj
 */
@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @Autowired
    private TCCAccountService tccAccountService;

    @RequestMapping("/debit")
    public Boolean debit(String userId, int money) throws Exception {
        // 用户账户扣款
        accountService.debit(userId, money);
        return true;
    }

    @RequestMapping("/tcc/debit")
    public Boolean tccDebit(String userId, int money) throws Exception {
        // 用户账户扣款
        tccAccountService.debit(userId, money);
        return true;
    }

}
